const path = require("path");
const CompressionWebpackPlugin = require("compression-webpack-plugin");
function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  productionSourceMap: false,
  configureWebpack: () => {
    if (process.env.NODE_ENV !== "production") return;
    return {
      plugins: [
        new CompressionWebpackPlugin({
          test: /\.(js|css)(\?.*)?$/i, //需要压缩的文件正则
          threshold: 10240, //文件大小大于这个值时启用压缩
          deleteOriginalAssets: false, //压缩后保留原文件
        }),
      ],
    };
  },
  chainWebpack: (config) => {
    config.resolve.alias.set("@", resolve("src"));
  },
};
